import base64
import imghdr
from flask import url_for


def ImageAllow(file):
    file_format = imghdr.what(file)
    return file_format in ['png', 'jpg', 'jpeg', 'gif']

def ImageDefault():
    return url_for('static', filename='default.jpg')

def ImageEncode(img):
    return  base64.b64encode(img).decode('utf-8')

